#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
using namespace std;
class solution {
public:
	void reSortArray(vector<int>& array) {
	if (array.empty()) {
		return;
	}
	int k = array.size() - 1; 
	for (int i = 0; i < k; ++i) {
		if (array[i] % 2 != 0) {
			while (array[k] % 2 != 0 && k > i) {
				k--;
			}
			if (k > i) {
				swap(array[i], array[k]);
				k--;
			}
		} 
	}
	for (int i = 0; i < array.size(); i++) {
		cout << array[i] << " ";
	}
	cout << endl;
}
};
int main() {
	solution s;
	vector<int> array = { 1,2,3,4,5,6 };
	s.reSortArray(array);
}